<template>
  <div class="flex flex-col h-full">
    <SearchContainer @reset="() => formRef.resetFields()" @search="getData()">
      <a-form ref="formRef" class="flex-1" :model="formState" :label-col="{ style: { width: '70px' } }">
        <a-form-item name="bm" class="w-1/5">
          <a-input v-model:value="formState.bm" placeholder="药品编号/药品名称/商品名称/助记码" />
        </a-form-item>
      </a-form>
    </SearchContainer>
    <a-card class="mt-2 flex-1">
      <div class="flex mb-3">
        <BaseExportTxt name="西成药" code="000362" :search-params="formState" btn-name="导出" />
        <a-button type="primary" class="ml-2" @click="open = true">下载</a-button>
      </div>
      <BaseTable :scroll="{ x: 2500 }" column-code="000362" fill :loading="loading" :data-source="tableData" bordered :pagination="pagination">
        <template #bodyCell="{ column, index }">
          <template v-if="column.dataIndex === 'xh'">
            {{ index + 1 }}
          </template>
        </template>
      </BaseTable>
    </a-card>
    <searchModal v-model:open="open" @success="onSuccess" />
  </div>
</template>

<script setup>
import SearchContainer from '@/components/SearchContainer'
import BaseExportTxt from '../components/BaseExport'
import searchModal from './Edit'

const formRef = ref(null)
const formState = ref({ bm: '' })
const open = ref(false)

const onSuccess = () => {
  open.value = false
}
const { loading, tableData, getData, pagination } = useTable({
  url: '/insure/getybmlxzfblxxList',
  immediate: true,
  formatParams: () => {
    return {
      bm: formState.value.bm
    }
  }
})
</script>
<style lang="less" scoped>
.ant-picker {
  width: 100%;
}
</style>
